{include file="common/header"/}
<div class="fadeInUp animated headalert" style="padding-right: 20px"><br>
    <div class="layui-anim layui-anim-up">
        <form class="layui-form">
            <div class="layui-container">
                <div class="layui-row">
                    <div class="layui-form-item">
                        <label class="layui-form-label">评论内容</label>
                        <div class="layui-input-4">
                            <!-- 加载编辑器的容器 -->
                            <textarea class="layui-textarea layui-hide" name="content"  id="content" style="display: none;"></textarea>
                        </div>
                    </div>
                    <div class="layui-form-item">
                      <div class="layui-input-block">
                        <button type="submit" class="layui-btn layui-btns layui-btn-blue" lay-submit="" lay-filter="add">添加</button>
                        <button type="reset" class="layui-btn layui-btns layui-btn-primary">重置</button>
                      </div>
                    </div>
              </div>
            </div>
        </form>
    </div>
</div>
{include file="common/footer"/}
<script type="text/javascript">

var url = '{:url("commentadd")}';
layui.use(['form','layer','layedit'], function(){
    var form = layui.form
    ,layer = layui.layer
    ,layedit = layui.layedit
    ,$ = layui.jquery;
    var layeCon = layedit.build('content', {
        tool: [
            'strong' //加粗
            ,'italic' //斜体
            ,'underline' //下划线
            ,'del' //删除线

            ,'|' //分割线

            ,'left' //左对齐
            ,'center' //居中对齐
            ,'right' //右对齐
           /* ,'link' //超链接
            ,'unlink' //清除链接*/
            ,'face' //表情
           /* ,'image' //插入图片*/
           /* ,'help' //帮助*/
        ]
    });
    form.on('submit(add)', function(data){
        console.log(data.field)
        data.field.content = layedit.getContent(layeCon);
        $.post(url,data.field,function(res){
            if(res.code == 1){
                layer.msg(res.msg);
                setTimeout(function(){
                    window.parent.location.reload();//修改成功后刷新父界面
                }, 1000);
            }else{
                layer.msg(res.msg);
            }
        },'json')
        return false;
    });
});
</script>
